package com.common.ajax.server;

import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;

import javax.jws.WebMethod;
import javax.jws.WebService;

import org.dom4j.Document;


/**
 * <p>
 * IRequest
 * </p>
 * <p>
 * 用途：请求处理接口,所有要处理请求的类必须实现此接口
 * </p>
 * 
 * @author 周华彬(zhouhuabin@ctfo.com, zhou_hua_bin@163.com)
 * @version 0.0.1 2011-5-12
 *          <table style="border:1px solid gray;">
 *          <tr>
 *          <th width="100px">版本号</th>
 *          <th width="100px">动作</th>
 *          <th width="100px">修改人</th>
 *          <th width="100px">修改时间</th>
 *          </tr>
 *          <!-- 以 Table 方式书写修改历史 -->
 *          <tr>
 *          <td>0.0.0</td>
 *          <td>创建类</td>
 *          <td>zhb</td>
 *          <td>2011-5-12 下午03:18:57</td>
 *          </tr>
 *          <tr>
 *          <td>0.0.1</td>
 *          <td>创建类</td>
 *          <td>zhb</td>
 *          <td>2011-5-12 下午03:18:57</td>
 *          <td>0.0.2</td>
 *          <td>修改类</td>
 *          <td>xxx</td>
 *          <td>x年x月x日</td>
 *          </tr>
 *          </table>
 */
@WebService
public interface IRequest {
	
	public static final int ERROR_SUCCEED = 0;
	public static final int ERROR_UNKOWN_USER = -1;
	public static final int ERROR_PASSWORD_ERROR = -2;
	public static final int ERROR_IMGCODE_ERROR = -3;
	
	public static final int ERROR_CLASS_NOT_FOUND = -5;
	public static final int ERROR_METHOD_NOT_FOUND = -6;
	public static final int ERROR_ILLEGAL_ACCESS = -7;
	public static final int ERROR_INSTANTIATION = -8;
	public static final int ERROR_AXISFAULT_ACCESS = -9;

	public static final String ERROR_SUCCEED_DESC="执行成功";
	public static final String ERROR_UNKOWN_USER_DESC="用户不存在";
	public static final String ERROR_PASSWORD_ERROR_DESC="密码错误";
	public static final String ERROR_IMGCODE_ERROR_DESC="验证码错误";
	public static final String ERROR_CLASS_NOT_FOUND_DESC = "处理服务类错误(无法找到对应的处理器)";
	public static final String ERROR_METHOD_NOT_FOUND_DESC = "处理方法type错误(查无此方法)";
	public static final String ERROR_ILLEGAL_ACCESS_DESC = "不合法的访问,缺少必要的参数";
	public static final String ERROR_INSTANTIATION_DESC = "对象没有IRequest接口";
	public static final String ERROR_AXISFAULT_DESC = "webservice调用出错";

	public static final int ERROR_SQL_ACCESS = -10;
	public static final String ERROR_SQL_DESC = "调用数据库出错";

	public static final int ERROR_RUNTIME_ACCESS = -11;
	public static final String ERROR_RUNTIME_DESC = "运行时出错";

	public static final int ERROR_INVOCATIONTARGET_ACCESS = -12;
	public static final String ERROR_INVOCATIONTARGET_DESC = "调用方法出错";

	public static final int ERROR_SECURITY_ACCESS = -13;
	public static final String ERROR_SECURITY_DESC = "类安全错误";


	public static final String XML_REQUEST = "request";
	public static final String XML_RESPONSE = "response";
	public static final String XML_TYPE = "type";
	public static final String XML_DATA = "data";
	public static final String XML_SERVER = "server";
	public static final String XML_RESULT = "result";
	public static final String XML_MSG = "msg";
	public static final String XML_USERNAME = "userName";
	public static final String XML_PASSWORD = "password";
	/**
	 * 通用的文档参数处理接口 ，本地处理时推荐用此接口
	 * @param doc
	 * @param session
	 * @return
	 * @throws SecurityException
	 * @throws NoSuchMethodException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 * @throws SQLException
	 * @throws RuntimeException
	 */
	@WebMethod(operationName="requestDoc")
	public Document request(Document doc, SessionMap session)
			throws SecurityException, NoSuchMethodException,
			IllegalAccessException, InvocationTargetException, SQLException,
			RuntimeException;
	
	
	/**
	 * 通用的字符串xml参数处理接口   ，远程处理时推荐用此接口
	 * @param xmlStr
	 * 通用xml请求结构
	 * <?xml version="1.0" encoding="UTF-8"?>
	 * <request server="service.monitorUserService">
	 * 	<data type="SysOperatorLogin" userName="admin" password="xxx">
	 * 		<MonitorUser userName="admin" password="c984aed014aec7623a54f0591da07a85fd4b762d" imgCode="aegf"/>
	 * 	</data>
	 * </request>
	 * @param session
	 * @return
	 * @throws SecurityException
	 * @throws NoSuchMethodException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 * @throws SQLException
	 * @throws RuntimeException
	 */
	@WebMethod(operationName="requestStr")
	public String request(String xmlStr, SessionMap session)
			throws SecurityException, NoSuchMethodException,
			IllegalAccessException, InvocationTargetException, SQLException,
			RuntimeException;
}
